<?php
class Vs_Factory
{
	private static $prefix	= 'Vs_';
	
	private function __construct()
	{
	}	
	
	public function __clone()
	{
	}
	
	public static function table ( $name )
	{
	    $name = self::_name($name);
	    
		$className = self::$prefix . $name . '_Table';	
		
		if ( !Zend_Registry::isRegistered($className) ){
		
			Zend_Registry::set( $className, new $className);
			
		}
		
		return Zend_Registry::get($className);
	}
	
	public static function mapper ( $name )
	{
	
		$className = self::$prefix . $name . '_Mapper';	
		
		if ( !Zend_Registry::isRegistered($className) ){
		
			Zend_Registry::set( $className, new $className);
			
		}
		
		return Zend_Registry::get($className);
	}
	
	public static function collection ( $name )
	{
	    $name = self::_name($name);
	    
		$className = self::$prefix . $name . '_Collection';
		
		return new $className;
	}
	
	public static function entity ( $name, $data )
	{
	    $name = self::_name($name);
	    
		$className = self::$prefix . $name;	
		
		return new $className($data);
	}
	
	
	
	
	protected static function _name( $name )
	{
	    if ($name instanceof Vs_Mapper){
	        $name = next(explode("_", get_class($name)));
	    }
	    
	    return $name;
	} 
	
}